<?php require_once('../Connections/webtintuc.php'); ?>
<?php
// Load the common classes
require_once('../includes/common/KT_common.php');

// Load the tNG classes
require_once('../includes/tng/tNG.inc.php');

// Load the required classes
require_once('../includes/tfi/TFI.php');
require_once('../includes/tso/TSO.php');
require_once('../includes/nav/NAV.php');

// Make unified connection variable
$conn_webtintuc = new KT_connection($webtintuc, $database_webtintuc);

//Start Restrict Access To Page
$restrict = new tNG_RestrictAccess($conn_webtintuc, "../");
//Grand Levels: Level
$restrict->addLevel("1");
$restrict->Execute();
//End Restrict Access To Page

if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

// Filter
$tfi_listtheloai1 = new TFI_TableFilter($conn_webtintuc, "tfi_listtheloai1");
$tfi_listtheloai1->addColumn("theloai.TenTL", "STRING_TYPE", "TenTL", "%");
$tfi_listtheloai1->addColumn("theloai.ThuTu", "NUMERIC_TYPE", "ThuTu", "=");
$tfi_listtheloai1->addColumn("theloai.AnHien", "NUMERIC_TYPE", "AnHien", "=");
$tfi_listtheloai1->Execute();

// Sorter
$tso_listtheloai1 = new TSO_TableSorter("rstheloai1", "tso_listtheloai1");
$tso_listtheloai1->addColumn("theloai.TenTL");
$tso_listtheloai1->addColumn("theloai.ThuTu");
$tso_listtheloai1->addColumn("theloai.AnHien");
$tso_listtheloai1->setDefault("theloai.TenTL");
$tso_listtheloai1->Execute();

// Navigation
$nav_listtheloai1 = new NAV_Regular("nav_listtheloai1", "rstheloai1", "../", $_SERVER['PHP_SELF'], 10);

//NeXTenesio3 Special List Recordset
$maxRows_rstheloai1 = $_SESSION['max_rows_nav_listtheloai1'];
$pageNum_rstheloai1 = 0;
if (isset($_GET['pageNum_rstheloai1'])) {
  $pageNum_rstheloai1 = $_GET['pageNum_rstheloai1'];
}
$startRow_rstheloai1 = $pageNum_rstheloai1 * $maxRows_rstheloai1;

// Defining List Recordset variable
$NXTFilter_rstheloai1 = "1=1";
if (isset($_SESSION['filter_tfi_listtheloai1'])) {
  $NXTFilter_rstheloai1 = $_SESSION['filter_tfi_listtheloai1'];
}
// Defining List Recordset variable
$NXTSort_rstheloai1 = "theloai.TenTL";
if (isset($_SESSION['sorter_tso_listtheloai1'])) {
  $NXTSort_rstheloai1 = $_SESSION['sorter_tso_listtheloai1'];
}
mysql_select_db($database_webtintuc, $webtintuc);

$query_rstheloai1 = "SELECT theloai.TenTL, theloai.ThuTu, theloai.AnHien, theloai.idTL FROM theloai WHERE {$NXTFilter_rstheloai1} ORDER BY {$NXTSort_rstheloai1}";
$query_limit_rstheloai1 = sprintf("%s LIMIT %d, %d", $query_rstheloai1, $startRow_rstheloai1, $maxRows_rstheloai1);
$rstheloai1 = mysql_query($query_limit_rstheloai1, $webtintuc) or die(mysql_error());
$row_rstheloai1 = mysql_fetch_assoc($rstheloai1);

if (isset($_GET['totalRows_rstheloai1'])) {
  $totalRows_rstheloai1 = $_GET['totalRows_rstheloai1'];
} else {
  $all_rstheloai1 = mysql_query($query_rstheloai1);
  $totalRows_rstheloai1 = mysql_num_rows($all_rstheloai1);
}
$totalPages_rstheloai1 = ceil($totalRows_rstheloai1/$maxRows_rstheloai1)-1;
//End NeXTenesio3 Special List Recordset

$nav_listtheloai1->checkBoundries();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link href="main.css" rel="stylesheet" type="text/css" />
<link href="../includes/skins/mxkollection3.css" rel="stylesheet" type="text/css" media="all" />
<script src="../includes/common/js/base.js" type="text/javascript"></script>
<script src="../includes/common/js/utility.js" type="text/javascript"></script>
<script src="../includes/skins/style.js" type="text/javascript"></script>
<script src="../includes/nxt/scripts/list.js" type="text/javascript"></script>
<script src="../includes/nxt/scripts/list.js.php" type="text/javascript"></script>
<script type="text/javascript">
$NXT_LIST_SETTINGS = {
  duplicate_buttons: true,
  duplicate_navigation: true,
  row_effects: true,
  show_as_buttons: true,
  record_counter: true
}
</script>
<style type="text/css">
  /* Dynamic List row settings */
  .KT_col_TenTL {width:140px; overflow:hidden;}
  .KT_col_ThuTu {width:140px; overflow:hidden;}
  .KT_col_AnHien {width:140px; overflow:hidden;}
</style>
</head>

<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td id="banner" colspan="2">TIN TỨC ONLINE. TRANG QUẢN TRỊ</td>
  </tr>
  <tr>
    <td width="150" valign="top" id="left"><table id="menu" width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td><a href="index.php">Trang chủ</a></td>
      </tr>
      <tr>
        <td><a href="listTheLoai.php"> thể loại</a></td>
      </tr>
      <tr>
        <td><a href="listLoaiTin.php"> loại tin</a></td>
      </tr>
      <tr>
        <td><a href="listTin.php"> Tin</a><a href="listUsers.php">Users</a></td>
      </tr>
      <tr>
        <td><a href="../index.php"> Thoát</a></td>
      </tr>
      <tr>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
      </tr>
    </table></td>
    <td valign="top" id="right">&nbsp;
      <div class="KT_tng" id="listtheloai1">
        <h1> Theloai
          <?php
  $nav_listtheloai1->Prepare();
  require("../includes/nav/NAV_Text_Statistics.inc.php");
?>
        </h1>
        <div class="KT_tnglist">
          <form action="<?php echo KT_escapeAttribute(KT_getFullUri()); ?>" method="post" id="form1">
            <div class="KT_options"> <a href="<?php echo $nav_listtheloai1->getShowAllLink(); ?>"><?php echo NXT_getResource("Show"); ?>
                  <?php 
  // Show IF Conditional region1
  if (@$_GET['show_all_nav_listtheloai1'] == 1) {
?>
                    <?php echo $_SESSION['default_max_rows_nav_listtheloai1']; ?>
                    <?php 
  // else Conditional region1
  } else { ?>
                    <?php echo NXT_getResource("all"); ?>
                    <?php } 
  // endif Conditional region1
?>
                  <?php echo NXT_getResource("records"); ?></a> &nbsp;
              &nbsp;
                <?php 
  // Show IF Conditional region2
  if (@$_SESSION['has_filter_tfi_listtheloai1'] == 1) {
?>
                  <a href="<?php echo $tfi_listtheloai1->getResetFilterLink(); ?>"><?php echo NXT_getResource("Reset filter"); ?></a>
                  <?php 
  // else Conditional region2
  } else { ?>
                  <a href="<?php echo $tfi_listtheloai1->getShowFilterLink(); ?>"><?php echo NXT_getResource("Show filter"); ?></a>
                  <?php } 
  // endif Conditional region2
?>
            </div>
            <table cellpadding="2" cellspacing="0" class="KT_tngtable">
              <thead>
                <tr class="KT_row_order">
                  <th> <input type="checkbox" name="KT_selAll" id="KT_selAll"/>
                  </th>
                  <th id="TenTL" class="KT_sorter KT_col_TenTL <?php echo $tso_listtheloai1->getSortIcon('theloai.TenTL'); ?>"> <a href="<?php echo $tso_listtheloai1->getSortLink('theloai.TenTL'); ?>">TenTL</a> </th>
                  <th id="ThuTu" class="KT_sorter KT_col_ThuTu <?php echo $tso_listtheloai1->getSortIcon('theloai.ThuTu'); ?>"> <a href="<?php echo $tso_listtheloai1->getSortLink('theloai.ThuTu'); ?>">ThuTu</a> </th>
                  <th id="AnHien" class="KT_sorter KT_col_AnHien <?php echo $tso_listtheloai1->getSortIcon('theloai.AnHien'); ?>"> <a href="<?php echo $tso_listtheloai1->getSortLink('theloai.AnHien'); ?>">AnHien</a> </th>
                  <th>&nbsp;</th>
                </tr>
                <?php 
  // Show IF Conditional region3
  if (@$_SESSION['has_filter_tfi_listtheloai1'] == 1) {
?>
                  <tr class="KT_row_filter">
                    <td>&nbsp;</td>
                    <td><input type="text" name="tfi_listtheloai1_TenTL" id="tfi_listtheloai1_TenTL" value="<?php echo KT_escapeAttribute(@$_SESSION['tfi_listtheloai1_TenTL']); ?>" size="20" maxlength="255" /></td>
                    <td><input type="text" name="tfi_listtheloai1_ThuTu" id="tfi_listtheloai1_ThuTu" value="<?php echo KT_escapeAttribute(@$_SESSION['tfi_listtheloai1_ThuTu']); ?>" size="20" maxlength="100" /></td>
                    <td><input type="text" name="tfi_listtheloai1_AnHien" id="tfi_listtheloai1_AnHien" value="<?php echo KT_escapeAttribute(@$_SESSION['tfi_listtheloai1_AnHien']); ?>" size="20" maxlength="100" /></td>
                    <td><input type="submit" name="tfi_listtheloai1" value="<?php echo NXT_getResource("Filter"); ?>" /></td>
                  </tr>
                  <?php } 
  // endif Conditional region3
?>
              </thead>
              <tbody>
                <?php if ($totalRows_rstheloai1 == 0) { // Show if recordset empty ?>
                  <tr>
                    <td colspan="5"><?php echo NXT_getResource("The table is empty or the filter you've selected is too restrictive."); ?></td>
                  </tr>
                  <?php } // Show if recordset empty ?>
                <?php if ($totalRows_rstheloai1 > 0) { // Show if recordset not empty ?>
                  <?php do { ?>
                    <tr class="<?php echo @$cnt1++%2==0 ? "" : "KT_even"; ?>">
                      <td><input type="checkbox" name="kt_pk_theloai" class="id_checkbox" value="<?php echo $row_rstheloai1['idTL']; ?>" />
                          <input type="hidden" name="idTL" class="id_field" value="<?php echo $row_rstheloai1['idTL']; ?>" />
                      </td>
                      <td><div class="KT_col_TenTL"><?php echo KT_FormatForList($row_rstheloai1['TenTL'], 20); ?></div></td>
                      <td><div class="KT_col_ThuTu"><?php echo KT_FormatForList($row_rstheloai1['ThuTu'], 20); ?></div></td>
                      <td><div class="KT_col_AnHien"><?php echo KT_FormatForList($row_rstheloai1['AnHien'], 20); ?></div></td>
                      <td><a class="KT_edit_link" href="formTheLoai.php?idTL=<?php echo $row_rstheloai1['idTL']; ?>&amp;KT_back=1"><?php echo NXT_getResource("edit_one"); ?></a> <a class="KT_delete_link" href="#delete"><?php echo NXT_getResource("delete_one"); ?></a> </td>
                    </tr>
                    <?php } while ($row_rstheloai1 = mysql_fetch_assoc($rstheloai1)); ?>
                  <?php } // Show if recordset not empty ?>
              </tbody>
            </table>
            <div class="KT_bottomnav">
              <div>
                <?php
            $nav_listtheloai1->Prepare();
            require("../includes/nav/NAV_Text_Navigation.inc.php");
          ?>
              </div>
            </div>
            <div class="KT_bottombuttons">
              <div class="KT_operations"> <a class="KT_edit_op_link" href="#" onclick="nxt_list_edit_link_form(this); return false;"><?php echo NXT_getResource("edit_all"); ?></a> <a class="KT_delete_op_link" href="#" onclick="nxt_list_delete_link_form(this); return false;"><?php echo NXT_getResource("delete_all"); ?></a> </div>
              <span>&nbsp;</span>
              <select name="no_new" id="no_new">
                <option value="1">1</option>
                <option value="3">3</option>
                <option value="6">6</option>
              </select>
              <a class="KT_additem_op_link" href="formTheLoai.php?KT_back=1" onclick="return nxt_list_additem(this)"><?php echo NXT_getResource("add new"); ?></a> </div>
          </form>
        </div>
        <br class="clearfixplain" />
      </div>
    <p>&nbsp;</p></td>
  </tr>
</table>
</body>
</html>
<?php
mysql_free_result($rstheloai1);
?>
